/*
 * IState.h
 *
 * Abstract Base class for all states within
 * the state machine.
 *
 * Author: Zachary Masiello
 * Author: Peter-John Rowe
 */

#ifndef ISTATE_H_
#define ISTATE_H_

#include <stddef.h>
#include <string>
#include <unistd.h>
#include <pthread.h>

using namespace std;

// State IDs
#define FULL_RESET_STATE_ID 11
#define INITIAL_DATA_STATE_ID 12
#define UNIT_SET_STATE_ID 13
#define SET_TIRE_CONF_STATE_ID 14
#define SPEED_MODE_STATE_ID 15
#define TIME_MODE_STATE_ID 16
#define DIST_MODE_STATE_ID 17
#define SET_TIRE_RUN_STATE_ID 18
#define OPERATING_STATE_ID 19

class Cyclometer;
class IState {
protected:
	/**
	 * State ID
	 */
	int ID;

	/**
	 * State Name - for printing purposes
	 */
	string stateName;
    // Stores context for callback
	Cyclometer* context;


public:
	/**
	 * Returns the ID belonging to the
	 * state.
	 */
	int getID();

	static void* run(IState *);
	/**
	 * Deconstructor
	 */
	virtual ~IState();

	/**
	 * Function pointer that stores pointer
	 * to activity
	 */
	//void (*activity)();
    virtual void activity() = 0;

	/**
	 * Function pointer that stores pointer
	 * to entry action
	 */
	virtual void entryAction() = 0;

	/**
	 * Function pointer that stores pointer
	 * to exit action
	 */
	virtual void exitAction() = 0;

	/**
	 * Returns the name of the state
	 */
	string getStateName();

	// Returns the context especially during callback
	Cyclometer* getContext();
};

#endif /* ISTATE_H_ */
